Concepts > QuickOPC Concepts > QuickOPC Features > QuickOPC User Interface Features > OPC Common Dialogs > OPC-UA Common Dialogs > OPC-UA Endpoint Dialog |
Icon:
If you do not know upfront which OPC-UA server and its endpoint to connect to, and do not have this information from any other source, your application will need to allow the user select the OPC server(s) to work with. The OPC-UA Endpoint Dialog (UAEndpointDialog class) allows the user to select the OPC server and its endpoint interactively from the list of OPC Unified Architecture servers provided by a LDS (Local Discovery Server) installed on a machine.
Here is an example of OPC-UA Endpoint dialog in action:
To run the dialog, call the ShowDialog method. If the result is equal to DialogResult.OK, the user has selected the OPC UA server, and information about it can be retrieved from the DiscoveryElement property.
Currently, the dialog shows endpoint provided by a LDS (Local Discovery Server) that you set by a static property on the EasyUAClient object. This approach may change in future.
// This example shows how to let the user browse for an OPC-UA server endpoint. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System.Windows.Forms; using OpcLabs.EasyOpc.UA.Forms.Browsing; namespace UAFormsDocExamples._UAEndpointDialog { static class ShowDialog { public static void Main1(IWin32Window owner) { var endpointDialog = new UAEndpointDialog { DiscoveryHost = "opcua.demo-this.com" }; DialogResult dialogResult = endpointDialog.ShowDialog(owner); if (dialogResult != DialogResult.OK) return; // Display results MessageBox.Show(owner, endpointDialog.DiscoveryElement.ToString()); } } }
# This example shows how to let the user browse for an OPC-UA server endpoint. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. using namespace OpcLabs.EasyOpc.UA.Forms.Browsing # The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows . Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll" # Instantiate the dialog object. $endpointDialog = New-Object UAEndpointDialog $endpointDialog.DiscoveryHost = "opcua.demo-this.com" $dialogResult = $endpointDialog.ShowDialog() if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) { return } # Display results Write-Host $endpointDialog.DiscoveryElement
' This example shows how to let the user browse for an OPC-UA server endpoint. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.UA.Forms.Browsing Namespace UAFormsDocExamples._UAEndpointDialog Friend Class ShowDialog Shared Sub Main1(owner As IWin32Window) Dim endpointDialog = New UAEndpointDialog() With { .DiscoveryHost = "opcua.demo-this.com" } Dim dialogResult As DialogResult = endpointDialog.ShowDialog(owner) If dialogResult <> DialogResult.OK Then Return End If ' Display results MessageBox.Show(owner, endpointDialog.DiscoveryElement.ToString()) End Sub End Class End Namespace
// This example shows how to let the user browse for an OPC-UA server endpoint. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. #include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files #include "ShowDialog.h" namespace _UAEndpointDialog { void ShowDialog1::Main() { // Initialize the COM library CoInitializeEx(NULL, COINIT_MULTITHREADED); { // _UAEndpointDialogPtr EndpointDialogPtr(__uuidof(UAEndpointDialog)); // EndpointDialogPtr->DiscoveryHost = L"opcua.demo-this.com"; // DialogResult dialogResult = EndpointDialogPtr->ShowDialog(NULL); _tprintf(_T("%d\n"), dialogResult); if (dialogResult == 1/*OK*/) { // Display results _tprintf(_T("%s\n"), (LPCTSTR)CW2CT(EndpointDialogPtr->DiscoveryElement->ToString)); } } // Release all interface pointers BEFORE calling CoUninitialize() CoUninitialize(); } }
// This example shows how to let the user browse for an OPC-UA server endpoint. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ShowDialog.Main; var EndpointDialog: UAEndpointDialog; begin // Instantiate the dialog object EndpointDialog := CoUAEndpointDialog.Create; EndpointDialog.DiscoveryHost := 'opcua.demo-this.com'; EndpointDialog.ShowDialog(nil); // IMPROVE: check the dialog result // Display results WriteLn(EndpointDialog.DiscoveryElement.ToString); end;
// This example shows how to let the user browse for an OPC-UA server endpoint. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. class procedure ShowDialog.Main; var EndpointDialog: OpcLabs_EasyOpcForms_TLB._UAEndpointDialog; DialogResult: System_Windows_Forms_TLB.DialogResult; begin // Instantiate the dialog object EndpointDialog := CoUAEndpointDialog.Create; EndpointDialog.DiscoveryHost := 'opcua.demo-this.com'; DialogResult := EndpointDialog.ShowDialog(nil); WriteLn(DialogResult); if DialogResult <> DialogResult_OK then Exit; // Display results WriteLn(EndpointDialog.DiscoveryElement.ToString); end;
REM This example shows how to let the user browse for an OPC-UA server endpoint. REM REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB . REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own REM a commercial license in order to use Online Forums, and we reply to every post. Private Sub ShowDialog_Main_Command_Click() OutputText = "" Dim EndpointDialog As New UAEndpointDialog EndpointDialog.DiscoveryHost = "opcua.demo-this.com" Dim DialogResult DialogResult = EndpointDialog.ShowDialog OutputText = OutputText & DialogResult & vbCrLf If DialogResult <> 1 Then ' OK Exit Sub End If ' Display results OutputText = OutputText & EndpointDialog.DiscoveryElement & vbCrLf End Sub
Rem This example shows how to let the user browse for an OPC-UA server endpoint. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Const DialogResult_OK = 1 Dim EndpointDialog: Set EndpointDialog = CreateObject("OpcLabs.EasyOpc.UA.Forms.Browsing.UAEndpointDialog") EndpointDialog.DiscoveryHost = "opcua.demo-this.com" Dim dialogResult: dialogResult = EndpointDialog.ShowDialog WScript.Echo dialogResult If dialogResult <> DialogResult_OK Then WScript.Quit End If ' Display results WScript.Echo EndpointDialog.DiscoveryElement
# This example shows how to let the user browse for an OPC-UA server endpoint. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from System.Windows.Forms import * from OpcLabs.EasyOpc.UA.Forms.Browsing import * endpointDialog = UAEndpointDialog() endpointDialog.DiscoveryHost = 'opcua.demo-this.com' dialogResult = endpointDialog.ShowDialog() print(dialogResult) if dialogResult != DialogResult.OK: exit() # Display results. print(endpointDialog.DiscoveryElement) print('Finished.')
If you want to change the parameters of the client object the component uses to perform its OPC operations, you can use the ClientSelector Property.
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Documentation Home, Send Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.